package com.ybkj.o2o.zhuanche.service.impl;

import com.ybkj.o2o.zhuanche.common.query.OrderReviewQuery;
import com.ybkj.o2o.zhuanche.entity.OrderReview;
import com.ybkj.o2o.zhuanche.entity.OrderReviewCriteria;
import com.ybkj.o2o.zhuanche.mapper.BaseMapper;
import com.ybkj.o2o.zhuanche.mapper.OrderReviewMapper;
import com.ybkj.o2o.zhuanche.service.OrderReviewService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DefaultOrderReviewService extends
    AbstractBaseService<OrderReview, OrderReviewCriteria, Long> implements OrderReviewService {

  @Autowired
  private OrderReviewMapper orderReviewMapper;

  @Override
  public BaseMapper<OrderReview, OrderReviewCriteria, Long> getMapper() {

    return orderReviewMapper;
  }

  @Override
  public int insert(OrderReview orderReview) {
    orderReview.setCreated(new Date());
    orderReview.setUpdated(new Date());
    return super.insert(orderReview);
  }

  @Override
  public int update(OrderReview orderReview) {

    orderReview.setUpdated(new Date());
    return super.update(orderReview);
  }

  @Override
  public OrderReview findByOrderIdAndAppKey(OrderReviewQuery orderReviewQuery) {
    return orderReviewMapper.findByOrderIdAndAppKey(orderReviewQuery);
  }

  @Override
  public Long countByDriver(OrderReviewQuery orderReviewQuery) {
    return orderReviewMapper.countByDriver(orderReviewQuery);
  }

  @Override
  public List<OrderReview> findByDriver(OrderReviewQuery orderReviewQuery) {
    return orderReviewMapper.findByDriver(orderReviewQuery);
  }

  @Override
  public Integer deleteById(Long id, String appKey) {
    return orderReviewMapper.deleteById(id,appKey);
  }

  @Override
  public OrderReview findOne(OrderReviewQuery orderReviewQuery) {
    return orderReviewMapper.findOne(orderReviewQuery);
  }

}
